<?php
/**
echo $result;
 * Created by PhpStorm.
 * User: steven
 * Date: 2017/11/13
 * Time: 下午8:33
 */

namespace app\api\model;


use think\Db;
use think\Exception;
use think\Model;

class Banner extends BaseModel {

    protected $hidden = ['delete_time','update_time'];
    public function items(){
        // 第一个关联模型的名字 第二个是外键，当前模型的主键
        return $this->hasMany('BannerItem','banner_id','id');
    }


    public static function getBannerByID($id){
        $banner = self::with(['items','items.img'])->find($id);
        return $banner;

    }
}